package com.jzhao.gper.observer;

import com.google.common.eventbus.EventBus;

public class Test {
    public static void main(String[] args) {
        Question question = new Question();
        question.setTitle("java观察者模式");
        question.setContent("观察者模式有几个方式实现？");
        question.setPublisher("jzhao");

        Teacher tom = new Teacher("tom");
        Teacher mic = new Teacher("mic");

        EventBus bus = new EventBus();
        bus.register(tom);
        bus.register(mic);
        bus.post(question);

        System.out.println("======发布新的问题======");
        question.setContent("观察者模式优缺点有哪些？");
        bus.unregister(mic);
        bus.post(question);
    }
}
